package org.aurora.framework.boot.common.rpc.response;

import java.io.Serial;
import java.util.List;

/**
 * PageResponse
 * <pre>
 * description:
 * create date: 2025-03-23 14:38:18
 * </pre>
 *
 * @author cao.yong
 */
public class PageResponse<T> extends DataResponse<List<T>> {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 当前页码
     */
    private final int pageNo;
    /**
     * 页大小
     */
    private final int pageSize;
    /**
     * 总数
     */
    private final int total;
    /**
     * 总页数
     */
    private final int totalPage;

    public PageResponse() {
        this(List.of(), 0, 1, 10);
    }

    public PageResponse(List<T> data, int total, int pageNo, int pageSize) {
        super(data);
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.total = total;
        this.totalPage = (total + pageSize - 1) / pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getTotal() {
        return total;
    }

    public int getTotalPage() {
        return totalPage;
    }
}
